import { defineConfig,UserConfigExport, ConfigEnv, preprocessCSS } from 'vite'
import vue from '@vitejs/plugin-vue'
//引入svg需要用到的插件
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"
import { viteMockServe } from 'vite-plugin-mock'

import path from 'path'
// https://vitejs.dev/config/
export default defineConfig(({command}:ConfigEnv)=>{ //command用于检测当前的开发环境
  return{
    plugins: [vue(),
      viteMockServe({
        mockPath: 'mock',
        localEnabled: command === 'serve', //保证开发阶段可以使用mock的接口
      }),
      createSvgIconsPlugin({
        iconDirs:[path.resolve(process.cwd(),'src/assets/icons')],
        symbolId:'icon-[dir]-[name]',
      }) 
    ],
    resolve: {
        alias: {
          '@': path.resolve(__dirname, './src')
        }
    },
    CSS:{
      preprocessCSS:{
        javascriptEnable:true,
        additionalData:'@import "./src/styles/variable.css";'
      }
    }
  }
  
  
})
